
/****** Object:  StoredProcedure [dbo].[web_insert_register]    Script Date: 10/19/2013 09:22:25 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'web_insert_register')
DROP PROCEDURE web_insert_register
GO

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[web_insert_register] 
	@imcode varchar(12),
	@impav varchar(70),
	@prcode varchar(12),
	@prpav varchar(40),
	@tipas int
AS
BEGIN
	DECLARE @eil_nr int

	SET NOCOUNT ON

	SET @eil_nr  = (SELECT max(n90_eil_nr) FROM N90_REGISTRAS where n90_tipas = @tipas)
	If @eil_nr is not null
		SET @eil_nr  = @eil_nr + 1
	else
		SET @eil_nr  = 1
		
	insert into N90_REGISTRAS  (n90_kodas_ks,n90_pav,n90_kodas,n90_pav1,n90_tipas,n90_eil_nr) 
	values (@imcode,@impav,@prcode,@prpav,@tipas,@eil_nr)


END

GO

